import pymysql
from pyecharts.charts import Pie
from pyecharts import options

db = pymysql.connect(
    host="localhost",
    port=3306,
    user="root",
    database="crawlerdemo",
    password="748wxc946",
    charset="utf8"
)
cursor = db.cursor()

sql = ("select job_place,count(job_id) from job group by job_place order by count(job_id) desc")
try:
    cursor.execute(sql)
    res = cursor.fetchall()
    pie = Pie()
    pie.add("单位/个",res)
    pie.set_global_opts(title_opts=options.TitleOpts(title="岗位最多的五个城市"))
    pie.render("pienum.html")
except:
    print("查询出错了")